<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
	href="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css">
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script
	src="http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js"></script>
</head>
<body>
	<%
	
		Connection con = null;
		try {
			Class.forName("com.mysql.jdbc.Driver");
			String url = "jdbc:mysql://192.168.0.2:3306/namecard";
			String sql = "UPDATE introduce SET name=?, age=?, tel=?, gender=?, addr=? WHERE ID=?";
			con = DriverManager.getConnection(url, "elo123123",
					"alflso!@34");
			PreparedStatement ps = con.prepareStatement(sql);
			ps.setString(1, request.getParameter("name"));
			ps.setString(2, request.getParameter("age"));
			ps.setString(3, request.getParameter("tel"));
			ps.setString(4, request.getParameter("gender"));
			ps.setString(5, request.getParameter("addr"));
			ps.setInt(6, Integer.parseInt(request.getParameter("ID")));
			ps.executeUpdate();
			response.sendRedirect("Research.jsp");
			
		} catch (Exception exc) {
			exc.printStackTrace();
			try{
				con.rollback();
			}
			catch(SQLException ec){
				ec.printStackTrace();
			}
		}
		finally{
			try {
				con.setAutoCommit(true);
			} catch (SQLException e) {				
				e.printStackTrace();
			}			
		}

	%>
</body>
</html>